//
// Created by ZYZ on 2020/6/15.
//

#include <stdio.h>
#include "test_stack.h"
#include "../../src/linear_stack/linear_stack.h"
#ifdef SELEMTYPE_INT

//StackTraverse 调用 Visit 函数输出栈中的元素
Status Visit(SElemType e) {
    printf("%d ", e);
    return OK;
}

//代码变灰色是因为判断了 SELEMTYPE_CHAR 宏定义
void test_stack() {

    SqStack stack;
    InitStack(stack);

    Push(stack, 2);
    Push(stack, 3);
    Push(stack, 5);
    Push(stack, 6);
    printf("-- 开始遍历 Stack -- \n");
    StackTraverse(stack, Visit);

    printf("-- 开始移除顶部元素 -- \n");
    SElemType popEle;
    Pop(stack, popEle);
    Pop(stack, popEle);

    printf("-- 再次遍历 Stack -- \n");
    StackTraverse(stack, Visit);

    printf("-- 开始获取顶部元素 -- \n");
    SElemType topEle;
    GetTop(stack, topEle);
    printf("Stack Top Ele = %d \n", topEle);

    printf("-- 开始打印长度 和 是否为空 -- \n");
    printf("StackLength = %d  \n", StackLength(stack));
    printf("StackEmpty = %d  \n", StackEmpty(stack));

    printf("-- 开始清空栈 -- \n");
    ClearStack(stack);

    printf("-- 开始销毁栈 -- \n");
    DestroyStack(stack);

    printf("StackEmpty = %d \n", StackEmpty(stack));
}
#endif
